using HKB.Common;
using System;
using System.Data;
using System.Data.SqlClient;
using System.Web;
namespace HKB.Web
{
	public class Shop_BankrollItem
	{
		private Conn conn = null;
		public DataRow thisDr;
		public Shop_BankrollItem(Conn _conn)
		{
			this.conn = _conn;
		}
		public Shop_BankrollItem()
		{
			this.conn = Text.GetComponent<Conn>("conn", HttpContext.Current.CurrentHandler);
		}
		public DataTable GetBanKrollItemByOrderFormID(int OrderFormID)
		{
			IDbDataParameter dbDataParameter = this.conn.CreateParameter("@OrderFormID", DbType.Int32, OrderFormID);
			return this.conn.GetDataTable("SELECT HLShop_BankrollItem.ItemID, HLShop_BankrollItem.UserID,  HLShop_BankrollItem.SalerID, HLShop_BankrollItem.DateAndTime,   HLShop_BankrollItem.Money, HLShop_BankrollItem.MoneyType,   HLShop_BankrollItem.CurrencyType, HLShop_BankrollItem.eBankID,   HLShop_BankrollItem.Income_PayOut, HLShop_BankrollItem.OrderFormID,   HLShop_BankrollItem.PaymentID, HLShop_BankrollItem.Remark,HLShop_BankrollItem.Status,   HL_User.UserName   FROM HLShop_BankrollItem INNER JOIN  HL_User ON HLShop_BankrollItem.UserID = HL_User.UserIDWHERE HLShop_BankrollItem.Income_PayOut!=2 and  (OrderFormID = @OrderFormID)", new IDbDataParameter[]
			{
				dbDataParameter
			});
		}
		public bool DeleteBankrollItem(string ItemID)
		{
			IDbDataParameter dbDataParameter = this.conn.CreateParameter("@ArrayItemID", DbType.String, ItemID);
			return this.conn.Execute("DELETE  [HLShop_BankrollItem] WHERE [ItemID]   in (SELECT * FROM fn_Split(@ArrayItemID,','))", new IDbDataParameter[]
			{
				dbDataParameter
			}) > 0;
		}
		public DataTable GetBankrollItemByDateIDBankUserIDSalerID(int SalerID, string UserName, int Bank, string BeginDate, string EndDate, int MoneyType, int Income_PayOut)
		{
			SqlParameter[] array = new SqlParameter[3];
			array[0] = this.conn.CreateParameter("@SalerID", SqlDbType.Int, SalerID);
			array[1] = this.conn.CreateParameter("@UserName", SqlDbType.VarChar, UserName);
			array[2] = this.conn.CreateParameter("@Bank", SqlDbType.Int, Bank);
			array[3] = this.conn.CreateParameter("@BeginDate", SqlDbType.VarChar, BeginDate);
			array[4] = this.conn.CreateParameter("@EndDate", SqlDbType.VarChar, EndDate);
			array[5] = this.conn.CreateParameter("@MoneyType", SqlDbType.Int, MoneyType);
			array[6] = this.conn.CreateParameter("@Income_PayOut", SqlDbType.Int, Income_PayOut);
			return this.conn.GetDataTable("Pr_GetBankrollItemByDateIDBankUserIDSalerID", array);
		}
		public DataTable GetBankrollItemByDateIDBankUserID(int UserID, string SalerName, int Bank, string BeginDate, string EndDate, int MoneyType, int Income_PayOut)
		{
			SqlParameter[] parameters = new SqlParameter[]
			{
				this.conn.CreateParameter("@UserID", SqlDbType.Int, UserID),
				this.conn.CreateParameter("@SalerName", SqlDbType.VarChar, SalerName),
				this.conn.CreateParameter("@Bank", SqlDbType.Int, Bank),
				this.conn.CreateParameter("@BeginDate", SqlDbType.VarChar, BeginDate),
				this.conn.CreateParameter("@MoneyType", SqlDbType.Int, MoneyType),
				this.conn.CreateParameter("@EndDate", SqlDbType.VarChar, EndDate),
				this.conn.CreateParameter("@Income_PayOut", SqlDbType.Int, Income_PayOut)
			};
			return this.conn.GetDataTable("Pr_GetBankrollItemByDateIDBankUserID", parameters);
		}
		public DataTable GetBankrollItemByItemID(int ItemID)
		{
			IDbDataParameter dbDataParameter = this.conn.CreateParameter("@ItemID", DbType.Int32, ItemID);
			return this.conn.GetDataTable("SELECT Bank, CurrencyType, DateAndTime, Income_PayOut, ItemID, Money, MoneyType, OrderFormID, PaymentID, Remark, SalerID, Status, UserID, eBankID FROM HLShop_BankrollItem WHERE (ItemID = @ItemID)", new IDbDataParameter[]
			{
				dbDataParameter
			});
		}
		public bool AddBankrollItem(int UserID, int SalerID, decimal Money, int MoneyType, int CurrencyType, int eBankID, int Bank, int Income_PayOut, int OrderFormID, int PaymentID, string Remark, string Status)
		{
			IDbDataParameter[] parameters = new IDbDataParameter[]
			{
				this.conn.CreateParameter("@UserID", DbType.Int32, UserID),
				this.conn.CreateParameter("@SalerID", DbType.Int32, SalerID),
				this.conn.CreateParameter("@Money", DbType.Decimal, Money),
				this.conn.CreateParameter("@MoneyType", DbType.Int32, MoneyType),
				this.conn.CreateParameter("@CurrencyType", DbType.Int32, CurrencyType),
				this.conn.CreateParameter("@eBankID", DbType.Int32, eBankID),
				this.conn.CreateParameter("@Bank", DbType.Int32, Bank),
				this.conn.CreateParameter("@Income_PayOut", DbType.Int32, Income_PayOut),
				this.conn.CreateParameter("@OrderFormID", DbType.Int32, OrderFormID),
				this.conn.CreateParameter("@PaymentID", DbType.Int32, PaymentID),
				this.conn.CreateParameter("@Remark", DbType.String, Remark),
				this.conn.CreateParameter("@Status", DbType.String, Status)
			};
			return this.conn.Execute("INSERT INTO [HLShop_BankrollItem] ([UserID], [SalerID], [DateAndTime], [Money], [MoneyType], [CurrencyType], [eBankID], [Bank], [Income_PayOut], [OrderFormID], [PaymentID], [Remark], [Status]) VALUES (@UserID, @SalerID, @DateAndTime, @Money, @MoneyType, @CurrencyType, @eBankID, @Bank, @Income_PayOut, @OrderFormID, @PaymentID, @Remark, @Status)", parameters) > 0;
		}
		public bool UpdateBankrollItem(int ItemID, decimal Money, string Remark, string Status)
		{
			IDbDataParameter[] parameters = new IDbDataParameter[]
			{
				this.conn.CreateParameter("@UserID", DbType.Int32, DBNull.Value),
				this.conn.CreateParameter("@SalerID", DbType.Int32, DBNull.Value),
				this.conn.CreateParameter("@Money", DbType.Decimal, Money),
				this.conn.CreateParameter("@MoneyType", DbType.Int32, DBNull.Value),
				this.conn.CreateParameter("@CurrencyType", DbType.Int32, DBNull.Value),
				this.conn.CreateParameter("@eBankID", DbType.Int32, DBNull.Value),
				this.conn.CreateParameter("@Bank", DbType.Int32, DBNull.Value),
				this.conn.CreateParameter("@Income_PayOut", DbType.Int32, DBNull.Value),
				this.conn.CreateParameter("@OrderFormID", DbType.Int32, DBNull.Value),
				this.conn.CreateParameter("@PaymentID", DbType.Int32, DBNull.Value),
				this.conn.CreateParameter("@Remark", DbType.String, Remark),
				this.conn.CreateParameter("@Status", DbType.String, Status),
				this.conn.CreateParameter("@DateAndTime", DbType.String, DBNull.Value),
				this.conn.CreateParameter("@ItemID", DbType.Int32, ItemID)
			};
			return this.conn.Execute("UPDATE [HLShop_BankrollItem] SET [UserID] = @UserID, [SalerID] = @SalerID, [DateAndTime] = @DateAndTime,  [Money] = @Money, [MoneyType] = @MoneyType, [CurrencyType] = @CurrencyType, [eBankID] = @eBankID, [Bank] = @Bank, [Income_PayOut] = @Income_PayOut, [OrderFormID] = @OrderFormID, [PaymentID] = @PaymentID, [Remark] = @Remark, [Status] = @Status WHERE (([ItemID] = @ItemID))", parameters) > 0;
		}
	}
}
